home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3909 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: Rezonet.net!news
  2. From: ray@ultimate-tech.com (Ray Dunn)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Basic Question on SWITCH
  5. Date: 29 Jan 1996 03:46:27 GMT
  6. Organization: Ultimate Technographics Inc.
  7. Message-ID: <4ehfuj$166g@ns.RezoNet.NET>
  8. References: <4e4cu4$95f@vixen.cso.uiuc.edu> <4e8p6m$n8q@ns.RezoNet.NET> <TANMOY.96Jan26162346@qcd.lanl.gov>
  9. NNTP-Posting-Host: 204.19.230.7
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-Newsreader: WinVN 0.99.7
  13.  
  14. In referenced article, Tanmoy Bhattacharya says...
  15. >
  16. >In article <3108ED49.987@cmt.lpr.mail.carel.fi> Ari Lukumies
  17. ><aril@cmt.lpr.mail.carel.fi> writes: 
  18. ><snip>
  19. >           if (strchr("0123456789", a))
  20. >                   ... /* It was a digit, do something */
  21. >
  22. >A special case for digits:
  23. >
  24. >if ((unsigned)(a-'0')<10)
  25. >   /* It _is_ a digit, do something */
  26. >
  27. >But then what is wrong with isdigit?
  28.  
  29. Indeed.  In the general case there is no guarantee that all the digits 
  30. are consecutive as they are in ASCII, so the use of isdigit is the only 
  31. portable way to go, although the strchr example works fine too, if 
  32. slowly.
  33.  
  34. [As a matter of interest, MS 'C' uses a character table with bits 
  35. defining all the various character types.  isdigit etc. uses this 
  36. table. MS provides profiling functions which allows the customization 
  37. of this table]
  38. -- 
  39. Ray Dunn (opinions are my own) | Phone: (514) 938 9050
  40. Montreal                       | Phax : (514) 938 5225
  41. ray@ultimate-tech.com          | Home : (514) 630 3749
  42.  
  43.